#include <iostream>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

// 模拟12306火车票
vector< int > station;

vector< vector< int > > order;

int M, N, Q;

int search( int a, int b ) {
    int min = N;
    for ( int i = a; i < b; i++ ) {
        min = std::min( station[ i ], min );
    }
    return min;
}

bool buy( int a, int b, int c ) {
    int remaintip = search( a, b );

    if ( remaintip < c ) {
        return false;
    }

    for ( int i = a; i < b; i++ ) {
        station[ i ] -= c;
    }

    order.push_back( vector< int >{ a, b, c } );

    return true;
}

bool goback( int a, int b, int c ) {

    auto it = order.begin();
    for ( ; it != order.end(); it++ ) {
        if ( ( *it )[ 0 ] == a && ( *it )[ 1 ] == b && ( *it )[ 2 ] == c ) {
            break;
        }
    }

    if ( it == order.end() ) {
        return false;
    }

    for ( int i = a; i < b; i++ ) {
        station[ i ] += c;
    }
    order.erase( it );
    return true;
}

int main() {

    cin >> M >> N >> Q;

    station.resize( M, N );

    for ( int i = 0; i < Q; i++ ) {
        char task;
        int  a, b, c;
        cin >> task;

        switch ( task ) {
        case 'Q': {
            cin >> a >> b;
            cout << search( a, b ) << endl;
            break;
        }
        case 'B': {
            cin >> a >> b >> c;
            bool res = buy( a, b, c );
            if ( res ) {
                cout << "OK!" << endl;
            }
            else {
                cout << "Fail!" << endl;
            }
            break;
        }
        case 'R': {
            cin >> a >> b >> c;
            bool res = goback( a, b, c );
            if ( res ) {
                cout << "OK!" << endl;
            }
            else {
                cout << "Fail!" << endl;
            }
            break;
        }
        }
    }
}

// 判断任务是否能够完成，拓扑排序
int main() {

    unordered_map< int, vector< int > > linklist;

    linklist[ 0 ].push_back( 1 );
    linklist[ 1 ].push_back( 0 );
    linklist[ 2 ].push_back( 3 );
    linklist[ 2 ].push_back( 0 );
    linklist[ 5 ].push_back( 6 );

    unordered_map< int, int > inDegree;

    for ( const auto& node : linklist ) {
        inDegree[ node.first ] = 0;
    }

    for ( const auto& node : linklist ) {
        for ( int neighbor : node.second ) {
            inDegree[ neighbor ]++;
        }
    }

    queue< int > sources;

    for ( const auto& node : inDegree ) {
        if ( node.second == 0 ) {
            sources.push( node.first );
        };
    }

    int count = 0;

    while ( sources.empty() ) {
        int node = sources.front();
        sources.pop();
        count++;

        for ( auto neighbor : linklist.find( node )->second ) {
            inDegree[ neighbor ]--;

            if ( inDegree[ neighbor ] == 0 ) {
                sources.push( neighbor );
            }
        }
    }

    if ( count == linklist.size() ) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
}
